package com.wisewin.circle.api.listener;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import javax.servlet.ServletContextListener;
//import javax.servlet.annotation.WebListener;

//监听容器启动状态
//项目初始化以后，初始化token
//@WebListener
@Component
public class TokenManagerListener implements ServletContextListener {

    final static Logger log = LoggerFactory.getLogger(TokenManagerListener.class);
//
//    @Value("${spring.profiles.active}")
//    private String active;
//
//    @Override
//    public void contextInitialized(ServletContextEvent sce){
//        //判断环境
//        if ("prod".equals(active)){
//            log.info("-------------TokenManagerListener contextInitialized1111111111111-------------");
//            TokenManager.init(WXConfig.PUBLIC_APPID,WXConfig.PUBLIC_appsecret);
//
//            log.info("-------------TokenManagerListener contextInitialized2222222222222-------------");
//            TokenManager.init(WXConfig.PUBLIC_APPID2,WXConfig.PUBLIC_appsecret2);
//        }else{
//            log.info("-------------非生产环境不进行定时刷新微信token-------------"+active);
//        }
//    }
//
//    @Override
//    public  void contextDestroyed(ServletContextEvent sce) {
//        if ("prod".equals(active)){
//            log.info("-------------TokenManagerListener contextDestroyed-------------");
//            TokenManager.destroyed();
//        }else{
//            log.info("-------------非生产环境不进行定时刷新微信token-------------"+active);
//        }
//    }

}
